package com.sixschmidts.clockenheimer;

import android.app.TabActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Chronometer;
import android.widget.TabHost;

public class Clockenheimer extends TabActivity {
	TabHost mTabHost = null;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        mTabHost = getTabHost();
        mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("Clock").setContent(R.id.clockFrameLayout));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Alarms").setContent(R.id.alarmview));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("Stopwatch").setContent(R.id.stopwatchLinearLayout));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test4").setIndicator("Timer").setContent(R.id.timerview));
        
        mTabHost.setCurrentTab(0);
        
        Button startStopButton = (Button)findViewById(R.id.startStopButton);
        startStopButton.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				Button button = (Button)v;
				Chronometer chrono = (Chronometer)findViewById(R.id.chronometer);
				if( button.getText().toString() == getString(R.string.stopwatch_start) )
				{
					// start the stopwatch and change the text
					chrono.start();
					button.setText(getString(R.string.stopwatch_stop));
				}
				else
				{
					chrono.stop();
					button.setText(getString(R.string.stopwatch_start));
				}
			}
		});
    }
}